import HttpClient from '../../utils/httpClient';

export function departmentTree(id, success, error) {
  HttpClient.request({
    url: '/department/findAll',
    data: {
      deptId: id
    },
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function createDepartment(data, success, error) {
  HttpClient.request({
    method: 'post',
    url: '/department/create',
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function departmentDetail(id, success, error) {
  HttpClient.request({
    url: `/department/detail/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function updateDepartment(id, data, success, error) {
  HttpClient.request({
    method: 'put',
    url: `/department/update/${id}`,
    data,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}

export function deleteDepartment(id, success, error) {
  HttpClient.request({
    method: 'delete',
    url: `/department/delete/${id}`,
    success: (responseData) => {
      success(responseData);
    },
    error: () => {
      error();
    }
  });
}
